<@override name="middle">
<div class="blogsbox" id="blogsbox">

</div>
<!--右边-->
 <div class="sidebar">
    <#include "../common/right.ftl"/>
 </div>

</@override>
<@extends name="/front/common/main.ftl"></@extends>
<input type="hidden" value="${currPage!'0'}" id="currPage" name="currPage">
<script>
    $(function () {
        requestArticle();
        //判断是不是到了最底部
        $(window).scroll(function () {
            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();
            if (scrollTop + windowHeight == (scrollHeight)) {
                requestArticle();
            }
        });

        function requestArticle() {
            var page = Number($("#currPage").val()) + 1;
            var flag = false;
            if(flag){

                return ;
            }
            flag = true;
            $.ajax({
                url: '${request.contextPath}' + "/home/article",
                data: {
                    page: page,
                    size: "10"
                },
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    flag = false;
                    if (!data || data == null || data.trim() == '') {
                        if (Boolean($("#noArticle").val()==null)) {
                            $("#blogsbox").append(" <div id=\"noArticle\" style=\"margin-bottom: 20px;padding:20px; text-align: center;\"><p>没有更多了</p></div>");
                        }
                    } else {
                        $("#currPage").val(page);
                        $("#blogsbox").append(data);
                    }
                }
            })
        }
    });
</script>